package com.song.osclient.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.song.osclient.App;
import com.song.osclient.OptionAlbumActivity;
import com.song.osclient.OptionMarkActivity;
import com.song.osclient.OptionPhotoActivity;
import com.song.osclient.OptionTextActivity;
import com.song.osclient.OptionVoiceActivity;
import com.song.osclient.R;
import com.song.osclient.OptionScanActivity;

/**
 * Created by Administrator on 2015/10/23.
 */
public class QuickOptionDialog extends Dialog implements View.OnClickListener {
    private Context mContext;

    public QuickOptionDialog(Context context) {
        this(context, R.style.noTitleDialog);
    }

    public QuickOptionDialog(Context context, int theme) {
        super(context, R.style.noTitleDialog);
        mContext = context;
    }

    protected QuickOptionDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_quick_option);
        initView();
    }

    @Override
    public void show() {
        super.show();
        Window dialogWindow = getWindow();
        dialogWindow.setDimAmount(0f);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        dialogWindow.setGravity(Gravity.LEFT | Gravity.BOTTOM);
        lp.width = App.getScreenWidth();
        dialogWindow.setAttributes(lp);
        dialogWindow.setWindowAnimations(R.style.noTitleDialog);
    }

    private void initView() {
        findViewById(R.id.option_text).setOnClickListener(this);
        findViewById(R.id.option_album).setOnClickListener(this);
        findViewById(R.id.option_mark).setOnClickListener(this);
        findViewById(R.id.option_scan).setOnClickListener(this);
        findViewById(R.id.option_voice).setOnClickListener(this);
        findViewById(R.id.option_photo).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.option_text:
                mContext.startActivity(new Intent(mContext, OptionTextActivity.class));
                break;
            case R.id.option_photo:
                mContext.startActivity(new Intent(mContext, OptionPhotoActivity.class));
                break;
            case R.id.option_scan:
                mContext.startActivity(new Intent(mContext, OptionScanActivity.class));
                break;
            case R.id.option_album:
                mContext.startActivity(new Intent(mContext, OptionAlbumActivity.class));
                break;
            case R.id.option_voice:
                mContext.startActivity(new Intent(mContext, OptionVoiceActivity.class));
                break;
            case R.id.option_mark:
                mContext.startActivity(new Intent(mContext, OptionMarkActivity.class));
                break;
        }
    }
}
